<template>
  <div class="index_box">
    <div v-for="(i,index) in titList" :key="index" class="index_item">
      <div class="index_tit">{{ i }}</div>
      <ul class="index_number">
        <li class="index_number_bg" v-for="(n,nindex) in numberList" :key="nindex">
          {{ listData[index] | filtersNumber(nindex) }}
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
export default {
  name:"Index",
  props:{
    list:{
      type:Array | Object,
      default:()=>{
        return ['31029','1557','781']
      }
    }
  },
  filters:{
    filtersNumber:(value,index)=>{
      let arr = value.split('');
      for (let i = 0; i < 5; i++) {
        if(arr.length<5) arr.unshift('0');
      }
      return value?arr[index]:0
    }
  },
  data(){
    return{
      titList:['文化元素总数','重点元素清单数','基因解码完成数'],
      numberList:[1,2,3,4,5]
    }
  },
  computed:{
    listData:{
      get(){
        return this.list
      }
    }
  }
}
</script>

<style>
.index_box{
  display: flex;
  flex-flow: row wrap;
  justify-content: space-around;
  align-items:center;
  height: calc(100% - 28px);
}
.index_item{
  width: 122px;
}
.index_tit{
  color: #fff;
  font-size: 15px;
  width: 100%;
  text-align: center;
  margin-bottom: 5px;
}
.index_number{
  width: 100%;
  display: flex;
  flex-flow: row nowrap;
  justify-content: space-between;
}
.index_number_bg{
  width: 22px;
  height: 55px;
  background: linear-gradient(to left top, #229bd2, #194483);
  font-size: 28px;
  text-align: center;
  line-height: 55px;
  color: #fff;
}
</style>
